.PHONY: all build run gotool clean help

BINARY=gin-hong-api
GIN-HONG-API-PATH=bin/api/
GIN-HONG-CMD-PATH=bin/cmd/
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

all: gotool build

build:
	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ${GIN-HONG-API-PATH} ${ROOT_DIR}
	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ${GIN-HONG-CMD-PATH} ${ROOT_DIR}/cmd/xueqiuv1.1/
	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ${GIN-HONG-CMD-PATH} ${ROOT_DIR}/cmd/xueqiuv1.1/
	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ${GIN-HONG-CMD-PATH} ${ROOT_DIR}/cmd/xueqiuv1.1/
	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ${GIN-HONG-CMD-PATH} ${ROOT_DIR}/cmd/xueqiuv1.1/

run:
	@go run ./

gotool:
	go fmt ./
	go vet ./

clean:
	@if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi

help:
	@echo "make - 格式化 Go 代码, 并编译生成二进制文件"
	@echo "make build - 编译 Go 代码, 生成二进制文件"
	@echo "make run - 直接运行 Go 代码"
	@echo "make clean - 移除二进制文件和 vim swap files"
	@echo "make gotool - 运行 Go 工具 'fmt' and 'vet'"
